from time import sleep

from celery import Celery

app = Celery("Hello", broker="redis://localhost:6379/1", backend="redis://localhost:6379/0")


@app.task
def my_task():

    sleep(5)

    print("正在执行任务")


if __name__ == '__main__':
    print("准备执行")
    my_task.delay()
    print("执行结束")